#!/usr/bin/env python3
"""
Dependency checker for m4s-merger
Checks if all required dependencies are installed.
"""

import sys
import subprocess
import importlib.util

def check_python_module(module_name):
    """Check if a Python module is available."""
    try:
        importlib.util.find_spec(module_name)
        return True
    except ImportError:
        return False

def check_system_command(command):
    """Check if a system command is available."""
    try:
        subprocess.run(['which', command], 
                      check=True, 
                      stdout=subprocess.DEVNULL, 
                      stderr=subprocess.DEVNULL)
        return True
    except subprocess.CalledProcessError:
        return False

def main():
    print("Checking dependencies for m4s-merger...")
    print("=" * 50)
    
    # Check Python modules
    python_modules = ['tkinter', 'subprocess', 'threading', 'os']
    print("Checking Python modules:")
    for module in python_modules:
        status = "✓" if check_python_module(module) else "✗"
        print(f"  {status} {module}")
    
    print("\nChecking system commands:")
    # Check system commands
    system_commands = ['ffmpeg']
    for command in system_commands:
        status = "✓" if check_system_command(command) else "✗"
        print(f"  {status} {command}")
    
    print("\n" + "=" * 50)
    print("Dependency check completed.")

if __name__ == "__main__":
    main()